#include "classvaluewidget.h"
#include "ui_classvaluewidget.h"
#include <QLayout>

ClassValueWidget::ClassValueWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ClassValueWidget)
{
    ui->setupUi(this);
    QGridLayout* layout = new QGridLayout(this);
    for(int i =1;i<=12;i++)
    {
        ValueShowItem* item = new ValueShowItem(this);
        item->setObjectName(QString("w_r%1").arg(i));
        item->hideStatusWdiget();
        item->setHead(QString("分选区%1").arg(i));
        mItemList<<item;
        layout->addWidget(item,(i-1)/4,(i-1)%4,1,1);
    }
    //layout->setContentsMargins(0,0,0,0);
    layout->setMargin(0);
    layout->setHorizontalSpacing(1);
    layout->setVerticalSpacing(0);
    setLayout(layout);
}

ClassValueWidget::~ClassValueWidget()
{
    delete ui;
}

void ClassValueWidget::setValue(int itemNo, const QString & vStr)
{
    mItemList.at(itemNo)->setValue(vStr);
}

void ClassValueWidget::setToWgtAndCnt(int itemNo, const QString & wgtCnt)
{
    mItemList.at(itemNo)->setCount(wgtCnt);
}

void ClassValueWidget::clearAll()
{
    foreach (auto item, mItemList) {
        item->clear();
    }
}
